using System;
using System.Collections.Generic;

using Sustainalytics.Entities.ESGRatings;

namespace Sustainalytics.ESGRatings.Computing.Entities
{


    public class GovernanceRatingOptions
    {
        public GovernanceRatingOptions()
        {
            this.Include = 0;
        }

        public Guid MatrixId { get; set; }

        public ESGRatingsOptions.IncludeFlags Include { get; set; }

    }


    public class ESGRatingsOptions
    {
        public List<Guid> CompaniesIds { get; set; }

        public Guid MatrixId { get; set; }

        public Guid RefUnivId { get; set; }

        public List<string> PeerGroups { get; set; }

        public List<string> IndustryGroups { get; set; }

        public IncludeFlags Include { get; set; }

        public ComparativeGroupEnum GroupBy { get; set; }

        public CompanyTypeEnum CompanyType { get; set; }

        public TemplateTypeEnum TemplateType { get; set; }

        public CompanyAttributesEnum ComputationCompanyAttributes
        {
            get { return GetComputingFlags(this.CompanyType, this.TemplateType); }
        }

        public Guid? SetId { get; set; }


        public ESGRatingsOptions()
        {
            this.GroupBy = ComparativeGroupEnum.PeerGroup;
            this.Include = 0;
            this.CompaniesIds = new List<Guid>();
            this.Include = IncludeFlags.IncludeAggregatedScores;
        }

        public static CompanyAttributesEnum GetComputingFlags(CompanyTypeEnum optionsType, TemplateTypeEnum optionsTemplate)
        {
            CompanyAttributesEnum attributes = 0;

            if (optionsType == CompanyTypeEnum.Public)
                attributes |= CompanyAttributesEnum.Public;

            if (optionsType == CompanyTypeEnum.Private)
                attributes |= CompanyAttributesEnum.Private;


            if (optionsTemplate == TemplateTypeEnum.TypeA)
                attributes |= CompanyAttributesEnum.TypeA;

            if (optionsTemplate == TemplateTypeEnum.TypeB)
                attributes |= CompanyAttributesEnum.TypeB;


            if ((optionsType == CompanyTypeEnum.Combined) && (optionsTemplate == TemplateTypeEnum.Combined))
                attributes = 0;

            return attributes;
        }


        [Flags]
        public enum CompanyAttributesEnum : byte
        {
            TypeA = 1,
            TypeB = 2,
            Public = 4,
            Private = 8
        }

        [Flags]
        public enum IncludeFlags
        {
            None = 0,
            IncludeIndWeightedScores = 1,
            IncludeRatings = 2,
            IncludeAggregatedScores = 4,
            IncludeWeights = 8,
            IncludeAggregatesWeights = 16
        }
    }



}